package com.yimu.ymblog.admin.controller;

import com.yimu.ymblog.common.domain.admin.vo.user.FindUserPageListReqVO;
import com.yimu.ymblog.common.domain.admin.vo.user.UpdateAdminUserPasswordReqVO;
import com.yimu.ymblog.common.domain.admin.vo.user.UpdateUserStatusReqVO;
import com.yimu.ymblog.admin.service.AdminUserService;
import com.yimu.ymblog.common.aspect.ApiOperationLog;
import com.yimu.ymblog.common.utils.PageResponse;
import com.yimu.ymblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin")
@Api(tags = "Admin 用户模块")
@Slf4j
public class AdminUserController {

    @Autowired
    private AdminUserService userService;

    @PostMapping("/password/update")
    @ApiOperation(value = "修改用户密码")
    @ApiOperationLog(description = "修改用户密码")
    public Response updatePassword(@RequestBody @Validated UpdateAdminUserPasswordReqVO updateAdminUserPasswordReqVO) {
        return userService.updatePassword(updateAdminUserPasswordReqVO);
    }

    @PostMapping("/user/info")
    @ApiOperation(value = "获取用户信息")
    @ApiOperationLog(description = "获取用户信息")
    public Response findUserInfo() {
        return userService.findUserInfo();
    }

    @PostMapping(value = "/user/list")
    @ApiOperation(value = "获取用户列表", httpMethod = "POST", response = Response.class, notes = "获取用户列表")
    @ApiOperationLog(description = "获取用户列表")
    public PageResponse findUserPageList(@RequestBody FindUserPageListReqVO findUserPageListReqVO) {
        return userService.findUserPageList(findUserPageListReqVO);
    }

    @PostMapping(value = "/user/changeStatus")
    @ApiOperation(value = "改变用户状态（禁用启用）", httpMethod = "POST", response = Response.class, notes = "改变用户状态（禁用启用）")
    @ApiOperationLog(description = "改变用户状态（禁用启用）")
    public Response changeUserStatus(@RequestBody UpdateUserStatusReqVO updateUserStatusReqVO) {
        return userService.changeUserStatus(updateUserStatusReqVO);
    }

}